var a = getApp();

Page({
    data: {
        classify_name: "",
        isOpen: "",
        judgeState: !0,
        classify_id: "",
        store_id: "",
        level: ""
    },
    onLoad: function(a) {
        a.classify_id && this.setData({
            classify_id: a.classify_id
        }), a.store_id && this.setData({
            store_id: a.store_id
        }), a.level && this.setData({
            level: a.level
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    sureAdd: function() {
        var t = "";
        "1" == this.data.isOpen ? t = 1 : "0" == this.data.isOpen && (t = 0);
        var e = this, s = a.getNetAddresss("plugin.store-cashier.frontend.store.goods-category.add-category"), i = {};
        e.judge(), 1 == e.data.judgeState ? (i = "add" == e.data.classify_id ? {
            store_id: e.data.store_id,
            name: e.data.classify_name,
            enabled: t,
            level: e.data.level
        } : {
            store_id: e.data.store_id,
            name: e.data.classify_name,
            enabled: t,
            parent_id: e.data.classify_id,
            level: e.data.level
        }, a._postNetWork({
            url: s,
            showToastIn: !1,
            data: i,
            success: function(a) {
                var t = a.data;
                1 == t.result ? wx.showToast({
                    title: "添加成功",
                    icon: "none",
                    duration: 1500,
                    success: function() {
                        setTimeout(function() {
                            wx.navigateTo({
                                url: "/packageC/o2o/GoodsClassify/GoodsClassify?store_id=" + e.data.store_id
                            });
                        }, 1500);
                    }
                }) : wx.showToast({
                    icon: "none",
                    title: t.msg,
                    duration: 1500
                });
            },
            fail: function(a) {}
        })) : wx.showToast({
            icon: "none",
            title: "分类信息不完整",
            duration: 1500
        });
    },
    judge: function() {
        this.setData({
            judgeState: !0
        }), "" != this.data.classify_name && "" != this.data.isOpen || this.setData({
            judgeState: !1
        });
    },
    classifyNameinp: function(a) {
        var t = a.detail.value;
        this.setData({
            classify_name: t
        });
    },
    isOpenChange: function(a) {
        var t = a.detail;
        this.setData({
            isOpen: t
        });
    }
});